using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Administration_Toolkit_v2
{
    public partial class AddApplication : Form
    {
        public AddApplication()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close(); 
        }

        private void ClearFields()
        {
            txtApplicationName.Text = String.Empty;  
            txtApplicationDescription.Text= String.Empty;
            txtDefaultBaseName.Text= String.Empty;
            txtBuild.Text= String.Empty;
            txtMajorVersion.Text= String.Empty;
            txtMinorVersion.Text= String.Empty;
            txtLocked.Text = String.Empty;


        }

        private void btnAddApplication_Click(object sender, EventArgs e)
        {
            try
            {

                string strApplicationName;
                string strApplicationDescription;
                string strDefaultBaseName;
                int intBuild;
                int intMajorVersion;
                int intMinorVersion;
                int intLocked;

                strApplicationName = txtApplicationName.Text;
                strApplicationDescription = txtApplicationDescription.Text;
                strDefaultBaseName = txtDefaultBaseName.Text;
                intBuild = System.Convert.ToInt32(txtBuild.Text);
                intMajorVersion = System.Convert.ToInt32(txtMajorVersion.Text);
                intMinorVersion = System.Convert.ToInt32(txtMinorVersion.Text);
                intLocked = System.Convert.ToInt32(txtLocked.Text);

                Utilities.CreateNewApplication(strApplicationName, strApplicationDescription, strDefaultBaseName, intBuild, intMajorVersion, intMinorVersion, intLocked);
                ClearFields();
                txtStatus.Text = "Application Added"; 
            }
            catch (Exception ex)
            {
                txtStatus.Text = ex.Message;  
            }
        }
        
    }
}